/*
 * @Author: liuYang codkly@gmail.com
 * @Date: 2022-12-05 17:23:28
 * @LastEditors: liuYang codkly@gmail.com
 * @LastEditTime: 2022-12-06 16:24:52
 * @FilePath: \coding\nest\blog_alpha\src\role\role.entity.ts
 * @Description:
 * 暂无备注
 */
import {
  Column,
  CreateDateColumn,
  DeleteDateColumn,
  Entity,
  PrimaryGeneratedColumn,
  ManyToOne,
  ManyToMany
} from 'typeorm';
import {BaseEntity} from '../../entity/base.entity'
import {UserinfoEntity} from '../userinfo/userinfo.entity'

@Entity('role')
export class RoleEntity extends BaseEntity{

  @Column({
    comment: '角色名',
  })
  name: string;

  @Column('simple-array', {
    nullable: true,
    comment: '权限',
  })
  permissions: string[];

  @Column('mediumtext', {
    nullable: true,
    comment: '备注',
  })
  remark: string;

  @ManyToMany(() => UserinfoEntity, userinfo => userinfo.roles) //双向绑定
  users: UserinfoEntity[];

  // @ManyToOne(() => UserinfoEntity, user => user.roles)
  // user: UserinfoEntity;
}
